package com.wu.llpsw.item.items;

import com.wu.llpsw.networking.ModMessage;
import com.wu.llpsw.networking.packet.backYuanLiMaxPacket;
import com.wu.llpsw.networking.packet.backYuanLiNowPacket;
import com.wu.llpsw.yuanli.energy.yuanliManager;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class yuanshi_one extends Item {

    private int myAdd;
    public yuanshi_one(Properties p_41383_,int my) {
        super(p_41383_);
        this.myAdd=my;
    }


    //添加描述
    @Override
    public void appendHoverText(ItemStack p_41421_, @Nullable Level p_41422_, List<Component> p_41423_, TooltipFlag p_41424_) {
        p_41423_.add(new TranslatableComponent("tooltip.wu.yuanshi_one.tooltip"));
    }

    //使用元石
    @NotNull
    @Override
    public InteractionResultHolder<ItemStack> use(@NotNull Level world, @NotNull Player player, @NotNull InteractionHand hand) {
        if (!world.isClientSide) {
            //Player player1= manager.getAllplayer();
            yuanliManager.use(player,this.myAdd);
            player.getCooldowns().addCooldown(this,20*4);
            // 从物品栏中减少一个物品
            player.getItemInHand(hand).shrink(1);

            }
        return InteractionResultHolder.success(player.getItemInHand(hand));
    }
}
